package com.pond.pond.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pond.common.log.annotation.Log;
import com.pond.common.log.enums.BusinessType;
import com.pond.common.security.annotation.RequiresPermissions;
import com.pond.pond.domain.PondSeat;
import com.pond.pond.service.IPondSeatService;
import com.pond.common.core.web.controller.BaseController;
import com.pond.common.core.web.domain.AjaxResult;
import com.pond.common.core.utils.poi.ExcelUtil;
import com.pond.common.core.web.page.TableDataInfo;

/**
 * 钓位信息Controller
 * 
 * @author ruoyi
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/seat")
public class PondSeatController extends BaseController
{
    @Autowired
    private IPondSeatService pondSeatService;

    /**
     * 查询钓位信息列表
     */
    @RequiresPermissions("pond:seat:list")
    @GetMapping("/list")
    public TableDataInfo list(PondSeat pondSeat)
    {
        startPage();
        List<PondSeat> list = pondSeatService.selectPondSeatList(pondSeat);
        return getDataTable(list);
    }

    /**
     * 导出钓位信息列表
     */
    @RequiresPermissions("pond:seat:export")
    @Log(title = "钓位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PondSeat pondSeat)
    {
        List<PondSeat> list = pondSeatService.selectPondSeatList(pondSeat);
        ExcelUtil<PondSeat> util = new ExcelUtil<PondSeat>(PondSeat.class);
        util.exportExcel(response, list, "钓位信息数据");
    }

    /**
     * 获取钓位信息详细信息
     */
    @RequiresPermissions("pond:seat:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pondSeatService.selectPondSeatById(id));
    }

    /**
     * 新增钓位信息
     */
    @RequiresPermissions("pond:seat:add")
    @Log(title = "钓位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody PondSeat pondSeat)
    {
        return toAjax(pondSeatService.insertPondSeat(pondSeat));
    }

    /**
     * 修改钓位信息
     */
    @RequiresPermissions("pond:seat:edit")
    @Log(title = "钓位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PondSeat pondSeat)
    {
        return toAjax(pondSeatService.updatePondSeat(pondSeat));
    }

    /**
     * 删除钓位信息
     */
    @RequiresPermissions("pond:seat:remove")
    @Log(title = "钓位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pondSeatService.deletePondSeatByIds(ids));
    }
}
